package com.cloud.drore.eboss.operation.controller;

import com.cloud.drore.eboos.common.base.PagePo;
import com.cloud.drore.eboos.common.base.ResultMessage;
import com.cloud.drore.eboos.common.constant.CommonConstant;
import com.cloud.drore.eboos.common.entity.dealer.OrderNotificationInitVo;
import com.cloud.drore.eboos.common.entity.dealer.OrderNotificationPo;
import com.cloud.drore.eboos.common.entity.dealer.OrderNotificationVo;
import com.cloud.drore.eboos.exception.BusinessException;
import com.cloud.drore.eboss.login.user.Anon;
import com.cloud.drore.eboss.operation.service.IOrderNotificationFeign;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 浙江卓锐科技股份有限公司 版权所有  Copyright 2018<br>
 *
 * @Description: <br>
 * @Project: eboos <br>
 * @CreateDate: Created in 2018/2/26 15:47 <br>
 * @Author: <a href="1451173193@qq.com">杨亮</a>
 */
@RestController
@RequestMapping("/orderNotification")
@Api(value = "/运营商-订单管理-订单通知信息接口", description = "运营商-订单管理-订单通知信息接口-杨亮")
public class OrderNotificationController {
    @Autowired
    IOrderNotificationFeign orderNotificationFeign;
    @PostMapping(value = "getOrderNotificationListByParam")
    public ResultMessage<List<OrderNotificationVo>> getOrderNotificationListByParam(@RequestBody PagePo<OrderNotificationPo> pagePo) throws BusinessException{
       ResultMessage resultMessage=orderNotificationFeign.getOrderNotificationListByParam(pagePo);
        if(resultMessage.getCode()!= CommonConstant.SUCCESS_CODE) {
            throw new BusinessException(CommonConstant.REMOTE_CALL_ERROR);
        }
        return resultMessage;
    }
    @GetMapping(value = "init")
    public ResultMessage init() throws BusinessException{
        ResultMessage<OrderNotificationInitVo> resultMessage=orderNotificationFeign.init();
        if(resultMessage.getCode()!=CommonConstant.SUCCESS_CODE) {
            throw new BusinessException(resultMessage.getMessage().toString());
        }
        return resultMessage;
    }
}
